/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package td3synchrosysrsx;

/**
 *
 * @author boomar
 */
public class Race {

    static Double val = 0.0;

    public class thread_plus extends Thread {

        @Override
        public void run() {
            for (int i = 0; i < 1000000; i++) {
                val += 1.0;
            }
        }
    }

    public class thread_moins extends Thread {

        @Override
        public void run() {
            for (int i = 0; i < 1000000; i++) {
                val -= 1.0;
            }
        }
    }

    public void go() throws InterruptedException {
        thread_plus Tp = new thread_plus();
        thread_moins Tm = new thread_moins();

        Tp.start();
        Tp.join();
        Tm.start();
        Tm.join();

        System.out.println(val);
    }

    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        Race r = new Race();
        r.go();
    }
}
